/**
 * Created by ptt on 2016/8/26/0028.
 */ 
define(["../maintools/Controller.js", "../../gis/gis/loadMap.js"], function (Controller, map) { 
	/*动画开始*/
	var loading = '<div class="spinner">'
				  +'<div class="spinner-container container1"><div class="circle1"></div>'
				  +'<div class="circle2"></div><div class="circle3"></div><div class="circle4"></div>'
				  +'</div>'
				  +'<div class="spinner-container container2"><div class="circle1"></div>'
				  +'<div class="circle2"></div><div class="circle3"></div><div class="circle4"></div>'
				  +'</div>'
				  +'<div class="spinner-container container3"><div class="circle1"></div>'
				  +'<div class="circle2"></div><div class="circle3"></div><div class="circle4"></div>'
				  +'</div>'
				  +'</div>';
	/*动画结束*/
	var nameUrl;
	var districtUrl;
	nameUrl = $("#nameUrl").val();
	districtUrl = $("#district").val();
	var ajaxUrl = {
			"yhUrl":"/ssjc/tl/projects!findYHInfo.action?roundId=",
			"bhUrl":"/ssjc/tl/projects!findDiseaseByRId.action?roundId=",
			"xxUrl":"/ssjc/tl/projects!findRepairByRId.action?roundId=",
			"byUrl":"/ssjc/tl/projects!findFitByRId.action?roundId=",
			"ljUrl":"/ssjc/lj/detectioninfo!gisRoadInfo.action?roadName="+nameUrl+"&filter_EQS_district="+districtUrl+"&filter_EQL_unitYear=",
			"idUrl":"/ssjc/lj/detectioninfo!gisDetectionPdf.action?unitYear=",
			"bgUrl":"/doc/docproject!openFileById.action?id=",
	};
	function format(val){
		var time = val;
		var date = new Date(time);
		var year = date.getFullYear();
		var month = date.getMonth()+1;
		var day = date.getDate();
		time = year+"-"+month+"-"+day;
		return time;
	};
   var messageMapp={
		"disease":"disease",
		"maintain":"roadFit",
	   "modify":"repair"
	};
    //initial
    Controller = Controller.Controller;
    map = map.map;
    var lifeMessage = Controller.create({
        elements: {},
        events: {
           "click span.columnClose": "columnClose",
           "click .column li":"changeData",
           "click .content .info":"mapLocation"
        },
        columnClose:function(){
        	$("#timeAxis .content li.title span").removeClass("on");
        	$("#timeAxis .content li.title i").removeClass("dh");
        	$("#details").removeClass("box_dowm").addClass("box_hide");
        	setTimeout(function(){
        		$("#details").removeClass("box_up");
        		$("#details .column").removeClass("color");
        		$("#details .content").removeClass("height");
        		$("#details .column li").removeClass("cur");
        	},450);
        },
        changeData:function(e){
        	var number = e.currentTarget.dataset.num;
        	var num = e.currentTarget.dataset.code;
        	var mark = e.currentTarget.dataset.mark;
        	var year = e.currentTarget.dataset.year;
        	var id = e.currentTarget.dataset.id;
        	var cid = e.currentTarget.dataset.cid;
        	var judge = e.currentTarget.dataset.judge;
        	var Url = ajaxUrl.yhUrl+id+"&cid="+cid;
        	$("#details .column li").addClass("cur");
        	switch(mark){
    			case "curing":
    	        	var curingIf = $("#details .column li").eq(0).attr("data-If");
    	        	var diseaseIf = $("#details .column li").eq(1).attr("data-If");
    	        	var maintainIf = $("#details .column li").eq(2).attr("data-If");
    	        	var modifyIf = $("#details .column li").eq(3).attr("data-If");
    	        	var checkpointIf = $("#details .column li").eq(4).attr("data-If");
    	        	$("#details .column li").eq(0).attr("data-If","false");
    	        	var collective = ((curingIf=="true")||(curingIf=="false"))&&(diseaseIf=="true")&&(maintainIf=="true")&&(modifyIf=="true")&&(checkpointIf=="true");
    				if(collective){
    					$(".column li").eq(num).addClass("on").siblings().removeClass("on");
    					$.ajax({
                    		url:Url,
                    		dataType:"json",
                    		type:'Get',
                    		beforeSend:function(){
                    			$("#details .content .demo").html(" ");
                    			$("#details .content .demo").html(loading);
    	            			$("#details").removeClass("box_hide").removeClass("box_up").addClass("box_dowm");
                    			$("#details .content .demo").removeClass("w_auto").addClass("w_fixed");
                    			$("#details .column").addClass("color");
                    			$("#details .content").addClass("height");
                    			$("#details .content .demo .spinner").addClass("cen");
                    			$("#details .column li").addClass("cur");
                    		},
                    		 complete:function(data){
                    				if(data.readyState==4){
                    			        var jsonData=JSON.parse(data.responseText);
                    			        function tim(){
                    			            setTimeout(function(){
                    			            	$("#details .content .demo").html(" ");
                    			            		$("#details .content .demo").append(getHtml(mark,jsonData));
                    			            		if(jsonData.type==1){
                        			            		$("#details .content li").eq(1).find(".value").html("公路");
                        			            	}else if(jsonData.type==2){
                        			            		$("#details .content li").eq(1).find(".value").html("市政道路");
                        			            	}
                        			        	$("#details .content .demo").append("<div style='clear:both;'></div>");
                        			        	$("#details").removeClass("box_hide").removeClass("box_dowm").addClass("box_up");
            	        			        	$("#details .content .demo").removeClass("w_fixed").addClass("w_auto");
            	        			        	$("#details .content .demo .spinner").addClass("cen");
                          			        	if(jsonData.length==0&&jsonData==null){
                          			        		$("#details .content .demo").html(" ");
                            			        	$("#details .content .demo").append("<font class='wu'>没有该记录！</font>");
                            			        }
                          			        	$("#details .column li").eq(0).attr("data-If","true");
                            			        $("#details .column li").eq(1).attr("data-If","true");
                            			        $("#details .column li").eq(2).attr("data-If","true");
                            			        $("#details .column li").eq(3).attr("data-If","true");
                            			        $("#details .column li").eq(4).attr("data-If","true");
                    			            },500);
                    			        }tim();
                    				}
                    	        }
                        });
    				}
    				$("#details .content #paging").hide();
    				break;
    			case "disease":
    			case "curing":
    	        	var curingIf = $("#details .column li").eq(0).attr("data-If");
    	        	var diseaseIf = $("#details .column li").eq(1).attr("data-If");
    	        	var maintainIf = $("#details .column li").eq(2).attr("data-If");
    	        	var modifyIf = $("#details .column li").eq(3).attr("data-If");
    	        	var checkpointIf = $("#details .column li").eq(4).attr("data-If");
    	        	$("#details .column li").eq(1).attr("data-If","false");
    	        	var collective = (curingIf=="true")&&((diseaseIf=="true")||(diseaseIf=="false"))&&(maintainIf=="true")&&(modifyIf=="true")&&(checkpointIf=="true");
    				if(collective){
    					$(".column li").eq(num).addClass("on").siblings().removeClass("on");
    					var ajUrl = ajaxUrl.bhUrl+id+'&year='+year+'&page.pageSize=10&page.pageNo=1&cid='+cid;
        				$.ajax({
                    		url:ajUrl,
                    		dataType:"json",
                    		type:'Get',
                    		beforeSend:function(){
                    			$("#details .content .demo").html(" ");
                    			$("#details .content .demo").html(loading);
    	            			$("#details").removeClass("box_hide").removeClass("box_up").addClass("box_dowm");
                    			$("#details .content .demo").removeClass("w_auto").addClass("w_fixed");
                    			$("#details .column").addClass("color");
                    			$("#details .content").addClass("height");
                    			$("#details .content .demo .spinner").addClass("cen");
                    			$("#details .column li").addClass("cur");
                    		},
                    		 complete:function(data){
                    				if(data.readyState==4){
                    			        var jsonData=JSON.parse(data.responseText);
                    			        function tim(){
                    			            setTimeout(function(){
                    			            	$("#details .content .demo").html(" ");
                    			            	for(var i=0;i<jsonData.length;i++){j=i+1;
                    			            		$("#details .content .demo").append(getHtml(mark,jsonData[i],j,format(jsonData[i].foundTime),i));
                    			            	}
                    			            	$("#details .content #paging").show();
                    			            	$("#details .content .demo").append("<div style='clear:both;'></div>");
                        			        	$("#details").removeClass("box_hide").removeClass("box_dowm").addClass("box_up");
            	        			        	$("#details .content .demo").removeClass("w_fixed").addClass("w_auto");
            	        			        	$("#details .content .demo .spinner").addClass("cen");
                          			        	//**************//
                          			        	if(jsonData.length==0&&jsonData==null){
                          			        		$("#details .content .demo").html(" ");
                            			        	$("#details .content .demo").append("<font class='wu'>没有该记录！</font>");
                            			        }
    	                      			        //判断，如果内容只有一页就隐藏分页栏
                    	        				if(number<=10){
                    	        						$("#details .content #paging").hide();
                    	        					}else{
                    	        						$("#details .content #paging").show();
                    	        					}
                    	        				if(number==0){
                    	        					$("#details .content .demo").append("<font class='wu'>没有该记录！</font>");
                            			       }
                          			        	//分页
                    	        				$(function(){
                    	        						$("#details .content #paging").cypager({pg_size:10,pg_nav_count:5,pg_total_count:number,pg_call_fun:function(count){
                    	        						ajUrl = ajaxUrl.bhUrl+id+'&year='+year+'&page.pageSize=10&page.pageNo='+count+'&cid='+cid;
                    	        							$.ajax({
                    	        		                		url:ajUrl,
                    	        		                		dataType:"json",
                    	        		                		type:"GET",
                    	        		                		beforeSend:function(){
                    	        		                			$("#details .content #paging").hide();
                    	        		                			$("#details .content .demo").html(" ");
                    	        		                			$("#details .content .demo").html(loading);
                    	        			            			$("#details").removeClass("box_hide").removeClass("box_up").addClass("box_dowm");
                    	        		                			$("#details .content .demo").removeClass("w_auto").addClass("w_fixed");
                    	        		                			$("#details .column").addClass("color");
                    	        		                			$("#details .content").addClass("height");
                    	        		                			$("#details .content .demo .spinner").addClass("cen");
                    	        		                			$("#details .column li").addClass("cur");
                    	        		                		},
                    	        		                		complete:function(data){
                	        		                			if(data.readyState==4){
                	        		                					var jsonData=JSON.parse(data.responseText);
    	            	        		                				$("#details .content .demo").html(" ");
    	            	                    			            	for(var i=0;i<jsonData.length;i++){j=i+1;
    	            	                    			            		$("#details .content .demo").append(getHtml(mark,jsonData[i],j,format(jsonData[i].foundTime),i));
    	            	                    			            	}
    	            	                    			            	$("#details .content #paging").show();
    	            	                    			            	$("#details .content .demo").append("<div style='clear:both;'></div>");
    	            	                        			        	$("#details").removeClass("box_hide").removeClass("box_dowm").addClass("box_up");
    	            	            	        			        	$("#details .content .demo").removeClass("w_fixed").addClass("w_auto");
    	            	            	        			        	$("#details .content .demo .spinner").addClass("cen");
    	            	                          			        	//**************//
    	            	                          			        	if(jsonData.length==0&&jsonData==null){
    	            	                          			        		$("#details .content .demo").html(" ");
    	            	                            			        	$("#details .content .demo").append("<font class='wu'>没有该记录！</font>");
    	            	                            			       }
                	        		                				}
                    	        		                		},
                    	        		                	});
                    	        						}});
                    	        					});
                    	        				$("#details .column li").eq(0).attr("data-If","true");
                            			        $("#details .column li").eq(1).attr("data-If","true");
                            			        $("#details .column li").eq(2).attr("data-If","true");
                            			        $("#details .column li").eq(3).attr("data-If","true");
                            			        $("#details .column li").eq(4).attr("data-If","true");
                    			            },500);
                    			        }tim();
                    				}
                    	        }
                        });
    				}
    				$("#details .content #paging").hide();
    				break;
    			case "maintain":
    				var curingIf = $("#details .column li").eq(0).attr("data-If");
    	        	var diseaseIf = $("#details .column li").eq(1).attr("data-If");
    	        	var maintainIf = $("#details .column li").eq(2).attr("data-If");
    	        	var modifyIf = $("#details .column li").eq(3).attr("data-If");
    	        	var checkpointIf = $("#details .column li").eq(4).attr("data-If");
    	        	$("#details .column li").eq(2).attr("data-If","false");
    	        	var collective = (curingIf=="true")&&(diseaseIf=="true")&&((maintainIf=="true")||(maintainIf=="fasle"))&&(modifyIf=="true")&&(checkpointIf=="true");
    				if(collective){
    					$(".column li").eq(num).addClass("on").siblings().removeClass("on");
    					var ajUrl = ajaxUrl.byUrl+id+'&year='+year+'&page.pageSize=10&page.pageNo=1&cid='+cid;
        				$.ajax({
                    		url:ajUrl,
                    		dataType:"json",
                    		type:'Get',
                    		beforeSend:function(){
                    			$("#details .content .demo").html(" ");
                    			$("#details .content .demo").html(loading);
    	            			$("#details").removeClass("box_hide").removeClass("box_up").addClass("box_dowm");
                    			$("#details .content .demo").removeClass("w_auto").addClass("w_fixed");
                    			$("#details .column").addClass("color");
                    			$("#details .content").addClass("height");
                    			$("#details .content .demo .spinner").addClass("cen");
                    			$("#details .column li").addClass("cur");
                    		},
                    		 complete:function(data){
                    				if(data.readyState==4){
                    			        var jsonData=JSON.parse(data.responseText);
                    			        function tim(){
                    			            setTimeout(function(){
                    			            	$("#details .content .demo").html(" ");
                    			            	for(var i=0;i<jsonData.length;i++){j=i+1;
                    			            		$("#details .content .demo").append(getHtml(mark,jsonData[i],j,format(jsonData[i].fitTime),i));
                    			            	}
                    			            	$("#details .content #paging").show();
                    			            	$("#details .content .demo").append("<div style='clear:both;'></div>");
                        			        	$("#details").removeClass("box_hide").removeClass("box_dowm").addClass("box_up");
            	        			        	$("#details .content .demo").removeClass("w_fixed").addClass("w_auto");
            	        			        	$("#details .content .demo .spinner").addClass("cen");
                          			        	if(jsonData.length==0&&jsonData==null){
                          			        		$("#details .content .demo").html(" ");
                            			        	$("#details .content .demo").append("<font class='wu'>没有该记录！</font>");
                            			       }
                          			        //判断，如果内容只有一页就隐藏分页栏
                    	        				if(number<=10){
                    	        						$("#details .content #paging").hide();
                    	        					}else{
                    	        						$("#details .content #paging").show();
                    	        					}
                    	        				if(number==0){
                    	        					$("#details .content .demo").append("<font class='wu'>没有该记录！</font>");
                            			       }
                          			        	//分页
                    	        				$(function(){
                    	        						$("#details .content #paging").cypager({pg_size:10,pg_nav_count:5,pg_total_count:number,pg_call_fun:function(count){
                    	        							ajUrl = ajaxUrl.byUrl+id+'&year='+year+'&page.pageSize=10&page.pageNo='+count+'&cid='+cid;
                    	        						//console.log(ajUrl);
                    	        							$.ajax({
                    	        		                		url:ajUrl,
                    	        		                		dataType:"json",
                    	        		                		type:"GET",
                    	        		                		beforeSend:function(){
                    	        		                			$("#details .content #paging").hide();
                    	        		                			$("#details .content .demo").html(" ");
                    	        		                			$("#details .content .demo").html(loading);
                    	        			            			$("#details").removeClass("box_hide").removeClass("box_up").addClass("box_dowm");
                    	        		                			$("#details .content .demo").removeClass("w_auto").addClass("w_fixed");
                    	        		                			$("#details .column").addClass("color");
                    	        		                			$("#details .content").addClass("height");
                    	        		                			$("#details .content .demo .spinner").addClass("cen");
                    	        		                			$("#details .column li").addClass("cur");
                    	        		                		},
                    	        		                		complete:function(data){
                	        		                			if(data.readyState==4){
                	        		                					var jsonData=JSON.parse(data.responseText);
    	            	        		                				$("#details .content .demo").html(" ");
    	            	                    			            	for(var i=0;i<jsonData.length;i++){j=i+1;
    	            	                    			            		$("#details .content .demo").append(getHtml(mark,jsonData[i],j,format(jsonData[i].fitTime),i));
    	            	                    			            	}
    	            	                    			            	$("#details .content #paging").show();
    	            	                    			            	$("#details .content .demo").append("<div style='clear:both;'></div>");
    	            	                        			        	$("#details").removeClass("box_hide").removeClass("box_dowm").addClass("box_up");
    	            	            	        			        	$("#details .content .demo").removeClass("w_fixed").addClass("w_auto");
    	            	            	        			        	$("#details .content .demo .spinner").addClass("cen");
    	            	                          			        	//**************//
    	            	                          			        	if(jsonData.length==0&&jsonData==null){
    	            	                          			        		$("#details .content .demo").html(" ");
    	            	                            			        	$("#details .content .demo").append("<font class='wu'>没有该记录！</font>");
    	            	                            			        }
                	        		                				}
                    	        		                		},
                    	        		                	});
                    	        						}});
                    	        					});
                    	        				$("#details .column li").eq(0).attr("data-If","true");
                            			        $("#details .column li").eq(1).attr("data-If","true");
                            			        $("#details .column li").eq(2).attr("data-If","true");
                            			        $("#details .column li").eq(3).attr("data-If","true");
                            			        $("#details .column li").eq(4).attr("data-If","true");
                    			            },500);
                    			        }tim();
                    				}
                    	        }
                        });
    				}
    				$("#details .content #paging").hide();
    				break;
    			case "modify":
    				var curingIf = $("#details .column li").eq(0).attr("data-If");
    	        	var diseaseIf = $("#details .column li").eq(1).attr("data-If");
    	        	var maintainIf = $("#details .column li").eq(2).attr("data-If");
    	        	var modifyIf = $("#details .column li").eq(3).attr("data-If");
    	        	var checkpointIf = $("#details .column li").eq(4).attr("data-If");
    	        	$("#details .column li").eq(3).attr("data-If","false");
    	        	var collective = (curingIf=="true")&&(diseaseIf=="true")&&(maintainIf=="true")&&((modifyIf=="false")||(modifyIf=="true"))&&(checkpointIf=="true");
    				if(collective){
    					$(".column li").eq(num).addClass("on").siblings().removeClass("on");
    					var ajUrl = ajaxUrl.xxUrl+id+'&year='+year+'&page.pageSize=10&page.pageNo=1&cid='+cid;
        				$.ajax({
                    		url:ajUrl,
                    		dataType:"json",
                    		type:'Get',
                    		beforeSend:function(){
                    			$("#details .content .demo").html(" ");
                    			$("#details .content .demo").html(loading);
    	            			$("#details").removeClass("box_hide").removeClass("box_up").addClass("box_dowm");
                    			$("#details .content .demo").removeClass("w_auto").addClass("w_fixed");
                    			$("#details .column").addClass("color");
                    			$("#details .content").addClass("height");
                    			$("#details .content .demo .spinner").addClass("cen");
                    			$("#details .column li").addClass("cur");
                    		},
                    		 complete:function(data){
                    				if(data.readyState==4){
                    			        var jsonData=JSON.parse(data.responseText)
                    			        function tim(){
                    			            setTimeout(function(){
                    			            	$("#details .content .demo").html(" ");
                    			            	for(var i=0;i<jsonData.length;i++){j=i+1;
                    			            		$("#details .content .demo").append(getHtml(mark,jsonData[i],j,null,i));
                    			            	}
                    			            	$("#details .content #paging").show();
                    			            	$("#details .content .demo").append("<div style='clear:both;'></div>");
                        			        	$("#details").removeClass("box_hide").removeClass("box_dowm").addClass("box_up");
            	        			        	$("#details .content .demo").removeClass("w_fixed").addClass("w_auto");
            	        			        	$("#details .content .demo .spinner").addClass("cen");
                          			        	if(jsonData.length==0&&jsonData==null){
                          			        		$("#details .content .demo").html(" ");
                            			        	$("#details .content .demo").append("<font class='wu'>没有该记录！</font>");
                            			       }
                          			        	 //判断，如果内容只有一页就隐藏分页栏
                    	        				if(number<=10){
                    	        						$("#details .content #paging").hide();
                    	        					}else{
                    	        						$("#details .content #paging").show();
                    	        					}
                    	        				if(number==0){
                    	        					$("#details .content .demo").append("<font class='wu'>没有该记录！</font>");
                            			       }
                          			        	//分页
                    	        				$(function(){
                    	        						$("#details .content #paging").cypager({pg_size:10,pg_nav_count:5,pg_total_count:number,pg_call_fun:function(count){
                    	        							ajUrl = ajaxUrl.xxUrl+id+'&year='+year+'&page.pageSize=10&page.pageNo='+count+'&cid='+cid;
                    	        						
                    	        							$.ajax({
                    	        		                		url:ajUrl,
                    	        		                		dataType:"json",
                    	        		                		type:"GET",
                    	        		                		beforeSend:function(){
                    	        		                			$("#details .content #paging").hide();
                    	        		                			$("#details .content .demo").html(" ");
                    	        		                			$("#details .content .demo").html(loading);
                    	        			            			$("#details").removeClass("box_hide").removeClass("box_up").addClass("box_dowm");
                    	        		                			$("#details .content .demo").removeClass("w_auto").addClass("w_fixed");
                    	        		                			$("#details .column").addClass("color");
                    	        		                			$("#details .content").addClass("height");
                    	        		                			$("#details .content .demo .spinner").addClass("cen");
                    	        		                			$("#details .column li").addClass("cur");
                    	        		                		},
                    	        		                		complete:function(data){
                	        		                			if(data.readyState==4){
                	        		                					var jsonData=JSON.parse(data.responseText);
    	            	        		                				$("#details .content .demo").html(" ");
    	            	                    			            	for(var i=0;i<jsonData.length;i++){j=i+1;
    	            	                    			            		$("#details .content .demo").append(getHtml(mark,jsonData[i],j,null,i));
    	            	                    			            	}
    	            	                    			            	$("#details .content #paging").show();
    	            	                    			            	$("#details .content .demo").append("<div style='clear:both;'></div>");
    	            	                        			        	$("#details").removeClass("box_hide").removeClass("box_dowm").addClass("box_up");
    	            	            	        			        	$("#details .content .demo").removeClass("w_fixed").addClass("w_auto");
    	            	            	        			        	$("#details .content .demo .spinner").addClass("cen");
    	            	                          			        	//**************//
    	            	                          			        	if(jsonData.length==0&&jsonData==null){
    	            	                          			        		$("#details .content .demo").html(" ");
    	            	                            			        	$("#details .content .demo").append("<font class='wu'>没有该记录！</font>");
    	            	                            			       }
                	        		                				}
                    	        		                		},
                    	        		                	});
                    	        						}});
                    	        					});
                    	        				$("#details .column li").eq(0).attr("data-If","true");
                            			        $("#details .column li").eq(1).attr("data-If","true");
                            			        $("#details .column li").eq(2).attr("data-If","true");
                            			        $("#details .column li").eq(3).attr("data-If","true");
                            			        $("#details .column li").eq(4).attr("data-If","true");
                    			            },500);
                    			        }tim();
                    				}
                    	        }
                        });
    				}
    				$("#details .content #paging").hide();
    				break;
    			case "checkpoint":
    				var special = $("#outline .blurb li").eq(0).find(".describe").html();
    				var specialVal = special.substr(0, 1);
    				var curingIf = $("#details .column li").eq(0).attr("data-If");
    	        	var diseaseIf = $("#details .column li").eq(1).attr("data-If");
    	        	var maintainIf = $("#details .column li").eq(2).attr("data-If");
    	        	var modifyIf = $("#details .column li").eq(3).attr("data-If");
    	        	var checkpointIf = $("#details .column li").eq(4).attr("data-If");
    	        	$("#details .column li").eq(4).attr("data-If","false");
    	        	var collective = (curingIf=="true")&&(diseaseIf=="true")&&(maintainIf=="true")&&(modifyIf=="true")&&((checkpointIf=="fasle")||(checkpointIf=="true"));
    	        	if(collective){
    					$(".column li").eq(num).addClass("on").siblings().removeClass("on");
    					if(judge=="true"){
        					$.ajax({
                        		url:ajaxUrl.ljUrl+year,
                        		dataType:"json",
                        		type:'Get',
                        		beforeSend:function(){
                        			$("#details .content .demo").html(" ");
                        			$("#details .content .demo").html(loading);
        	            			$("#details").removeClass("box_hide").removeClass("box_up").addClass("box_dowm");
                        			$("#details .content .demo").removeClass("w_auto").addClass("w_fixed");
                        			$("#details .column").addClass("color");
                        			$("#details .content").addClass("height");
                        			$("#details .content .demo .spinner").addClass("cen");
                        			$("#details .column li").addClass("cur");
                        		},
                        		 complete:function(data){
                        				if(data.readyState==4){
                        			        var jsonData=JSON.parse(data.responseText);
                        			        function tim(){
                        			            setTimeout(function(){
                        			            	$("#details .content .demo").html(" ");
                        			            	for(var i=0;i<jsonData[0].length;i++){
                        			            		$("#details .content .demo").append(getHtml(mark,jsonData[0][i]));
                        			            	}
                        			            	for(var i=0;i<jsonData[1].length;i++){
                        			            		$("#details .content .demo").append(getHtml('roadCheckpoint',jsonData[1][i]));
                        			            	}
                        			            	$("#details .content .demo").append("<div style='clear:both;'></div>");
                            			        	$("#details").removeClass("box_hide").removeClass("box_dowm").addClass("box_up");
                	        			        	$("#details .content .demo .spinner").addClass("cen");
                              			        	if(jsonData[0].length==0&&jsonData[1].length==0){
                              			        		$("#details .content .demo").html(" ");
                                			        	$("#details .content .demo").append("<font class='wu'>没有该记录！</font>");
                                			       }
                              			        	$("#details .column li").eq(0).attr("data-If","true");
                                			        $("#details .column li").eq(1).attr("data-If","true");
                                			        $("#details .column li").eq(2).attr("data-If","true");
                                			        $("#details .column li").eq(3).attr("data-If","true");
                                			        $("#details .column li").eq(4).attr("data-If","true");
                        			            },500);
                        			        }tim();
                        				}
                        	        }
                            });
        				}else if(judge=="false"&&(specialVal=="G"||specialVal=="S")){
        					//相关报告！！！！
    			        	$.ajax({
                        		url:ajaxUrl.idUrl+year,
                        		dataType:"json",
                        		type:'Get',
                        		 complete:function(data){
                        				if(data.readyState==4){
                        			        var jsonData=JSON.parse(data.responseText);
                        			        if(jsonData!=""&&jsonData.length!=0){
                        			        	//window.open(appConfig.contPath+ajaxUrl.bgUrl+jsonData); 
                        			        	$("#details .content .demo").html(" ");
                        			        	$("#details .content .demo").append(
                    			        			'<li class="txt">基本信息</li>'
                    			        			+'<li><a style="display:block;margin-left:15px;" target="_blank" href="'+appConfig.contPath+ajaxUrl.bgUrl+jsonData+'">深圳市国省道路况检测分析与评价总报告</a></li>'
                        			        	);
                        			        }else{
                        			        	$("#details .content .demo").html(" ");
                        			        	$("#details .content .demo").append("<font class='wu'>没有该记录!</font>");
                        			        }
                        			        $("#details .column li").eq(0).attr("data-If","true");
                        			        $("#details .column li").eq(1).attr("data-If","true");
                        			        $("#details .column li").eq(2).attr("data-If","true");
                        			        $("#details .column li").eq(3).attr("data-If","true");
                        			        $("#details .column li").eq(4).attr("data-If","true");
                        				}
                        	        }
                            });
        				}else{
        					$("#details .content .demo").html(" ");
    			        	$("#details .content .demo").append("<font class='wu'>没有该记录!</font>");
    			        	$("#details .column li").eq(0).attr("data-If","true");
        			        $("#details .column li").eq(1).attr("data-If","true");
        			        $("#details .column li").eq(2).attr("data-If","true");
        			        $("#details .column li").eq(3).attr("data-If","true");
        			        $("#details .column li").eq(4).attr("data-If","true");
        				}
    				}
    				$("#details .content #paging").hide();
    				break;
    			default:;
        	}
			Querycuring(mark,id,year);
        },
        mapLocation:function(e){
        	//选中特效
        	var code = e.currentTarget.dataset.code;
        	$("#details .content .info").eq(code).find(".identification").addClass("on").parent().siblings().find(".identification").removeClass("on");
        	$("#details .content .info").eq(code).addClass("on").siblings().removeClass("on");
        	//交互
        	var curentNode= e.currentTarget;
			if(curentNode.hasAttribute("data-type")&&curentNode.hasAttribute("data-id")){
					var curringType=curentNode.getAttribute("data-type");
				   var curringId=curentNode.getAttribute("data-id");
				Querycuring(curringType,curringId);
			}
        },
        template: "#deta",
    });
    function getHtml(mark,data,i,time,code){
    	var html = "";
    	switch (mark){
	    	case "curing":
				html =
					'<li class="txt">基本信息</li>'
        			+'<li><div class="name"> 道路类型：</div><div class="value valu">'+Pengtu.buildCodeName(2011,data.type)+'</div><div style="clear:both;"></div></li>'
        			+'<li><div class="name"> 道路全称：</div><div class="value">'+data.roadName+'</div><div style="clear:both;"></div></li>'
        			+'<li><div class="name"> 起点：</div><div class="value valu">'+data.startName+'</div></li>'
        			+'<li><div class="name"> 终点：</div><div class="value valu">'+data.endName+'</div><div style="clear:both;"></div></li>'
        			+'<li><div class="name"> 养护标段：</div><div class="value valu">'+data.mainDistrict+'</div></li>'
        			+'<li><div class="name"> 区：</div><div class="value valu">'+data.area+'</div><div style="clear:both;"></div></li>'
        			+'<li><div class="name"> 街道：</div><div class="value valu">'+data.districtNum+'</div><div style="clear:both;"></div></li>'
        			+'<li><div class="name"> 管养单位：</div><div class="value">'+data.manageOrg+'</div><div style="clear:both;"></div></li>'
        			+'<li><div class="name"> 养护单位：</div><div class="value">'+data.maintainOrg+'</div><div style="clear:both;"></div></li>'
        			+'<li><div class="name"> 监管单位：</div><div class="value">'+data.supervisionOrg+'</div><div style="clear:both;"></div></li>';
        		break;
			case "disease":
				html =
					'<div class="info" data-code="'+code+'" data-type="'+mark+'" data-id="'+data.id+'"  data-name="3333">'
					+'<div class="identification" >'+i+'</div>'
					+'<div class="infoContent">'
					+'<div class="list"><p class="name">道路名称：<font>'+data.roundName+'</font></p><p class="time">发现时间：<font>'+time+'</font></p></div><div style="clear:both;"></div>'
					+'<div class="list"><p class="proName">病害描述：</p><p class="project">'+data.describe+'</p></div><div style="clear:both;"></div>'
					+'<div class="list"><p class="proName">项目位置：</p><p class="project">'+data.landmark+'</p></div><div style="clear:both;"></div>'
					+'<div class="list"><p class="proName">详细信息：</p><p class="project"><a href="'+curingData[mark].dataQuery.detailUrl+data.caseNo+'" target="_blank">查看详情</a></p></div><div style="clear:both;"></div>'
					+'</div><div style="clear:both;"></div>'
					+'</div>';
				break;
			case "maintain":
				html =
					'<div class="info" data-code="'+code+'" data-type="'+mark+'" data-id="'+data.ddId+'"  data-name="3333">'
					+'<div class="identification" >'+i+'</div>'
					+'<div class="infoContent">'
					+'<div class="list"><p class="name">道路名称：<font>'+data.roadName+'</font></p><p class="time">台账日期：<font>'+time+'</font></p></div><div style="clear:both;"></div>'
					+'<div class="list"><p class="proName">保养描述：</p><p class="project">'+data.fitDescribe+'</p></div><div style="clear:both;"></div>'
					+'<div class="list"><p class="proName">位置标志：</p><p class="project">'+data.landmark+'</p></div><div style="clear:both;"></div>'
					+'<div class="list"><p class="proName">详细信息：</p><p class="project"><a href="'+curingData[mark].dataQuery.detailUrl+data.id+'" target="_blank">查看详情</a></p></div><div style="clear:both;"></div>'
					+'</div><div style="clear:both;"></div>'
					+'</div>';
				break;
			case "modify":
				html =
					'<div class="info" data-code="'+code+'" data-type="'+mark+'" data-id="'+data.ddId+'"  data-name="3333">'
					+'<div class="identification" >'+i+'</div>'
					+'<div class="infoContent">'
					+'<div class="list"><p class="name">道路名称：<font>'+data.roadName+'</font></p><p class="time">开始时间：<font>'+data.beginDate+'</font></p></div><div style="clear:both;"></div>'
					+'<div class="list"><p class="proName">保养描述：</p><p class="project">'+data.projectName+'</p></div><div style="clear:both;"></div>'
					+'<div class="list"><p class="proName">工程地点：</p><p class="project">'+data.projectLocation+'</p></div><div style="clear:both;"></div>'
					+'<div class="list"><p class="proName">申报表：</p><p class="project"><a href="'+curingData[mark].dataQuery.sbUrl+data.id+'" target="_blank">查看申报表</a></p></div><div style="clear:both;"></div>'
					+'<div class="list"><p class="proName">验收表：</p><p class="project"><a href="'+curingData[mark].dataQuery.ysUrl+data.id+'" target="_blank">查看验收表</a></p></div><div style="clear:both;"></div>'
					+'</div><div style="clear:both;"></div>'
					+'</div>';
				break;
			case "checkpoint":
				html=
					'<li class="txt">城镇道路养护技术状况评定</li>'
					+'<li><div class="name"> 道路名称：</div><div class="value valu">'+data.roadName+'</div></li>'
	    			+'<li><div class="name"> 道路编号：</div><div class="value valu">'+data.roadCode+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name"> 起点：</div><div class="value valu">'+data.startName+'</div></li>'
	    			+'<li><div class="name"> 终点：</div><div class="value valu">'+data.endName+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name special"> 路面养护对策：</div><div class="value valu">'+data.pavementMaintainDec+'</div><div style="clear:both;"></div></li>'
					+'<li><div class="name special"> 人行道养护对策：</div><div class="value valu">'+data.sidewalkMaintainDec+'</div><div style="clear:both;"></div></li>'
					+'<li><div class="name special"> 综合评价(PQI)：</div><div class="value specialValue">'+data.pqi+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name special"> 路面损坏(PCI)：</div><div class="value specialValue">'+data.pci+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name special"> 人行道质量(FQI)：</div><div class="value specialValue">'+data.fqi+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name special"> 横向力系数(SFC)：</div><div class="value specialValue">'+data.sfc+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name special"> 人行道状况(FCI)：</div><div class="value specialValue">'+data.fci+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name special"> 行驶质量(RQI)：</div><div class="value specialValue">'+data.rqi+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name special"> 弯沉(PSSI)：</div><div class="value specialValue">'+data.pssi+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name special"> 车行道(CL)：</div><div class="value specialValue">'+data.cl+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name special"> 人行道(PL)：</div><div class="value specialValue">'+data.pl+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name special"> 其实设施(QL)：</div><div class="value specialValue">'+data.ql+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name special"> 路基与排水(SDL)：</div><div class="value specialValue">'+data.sdl+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name special"> 综合完好率(RZ)：</div><div class="value specialValue">'+data.rz+'</div><div style="clear:both;"></div></li>';
				break;
			case "roadCheckpoint":
				html=
					'<li class="txt">公路技术状况评定</li>'
					+'<li><div class="name"> 道路名称：</div><div class="value valu">'+data.roadName+'</div></li>'
	    			+'<li><div class="name"> 道路编号：</div><div class="value valu">'+data.roadCode+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name"> 起点：</div><div class="value valu">'+data.startName+'</div></li>'
	    			+'<li><div class="name"> 终点：</div><div class="value valu">'+data.endName+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name roadSpecialTs"> 路面养护对策：</div><div class="value valu">'+data.maintainDec+'</div><div style="clear:both;"></div></li>'
					+'<li><div class="name roadSpecialTs"> 公路技术状况指数(MQI)：</div><div class="value specialValue">'+data.mqi+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name roadSpecialTs"> 路面使用性能指数(PQI)：</div><div class="value specialValue">'+data.pqi+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name roadSpecialTs"> 路面损坏(PCI)：</div><div class="value specialValue">'+data.pci+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name roadSpecialTs"> 路面行驶质量(RQI)：</div><div class="value specialValue">'+data.rqi+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name roadSpecialTs"> 路面车辙(RDI)：</div><div class="value specialValue">'+data.rdi+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name roadSpecialTs"> 路面抗滑性能(SRI)：</div><div class="value specialValue">'+data.sri+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name roadSpecialTs"> 路面结构强度指数(PSSI)：</div><div class="value specialValue">'+data.pssi+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name roadSpecialTs"> 路基技术状况指数(SCI)：</div><div class="value specialValue">'+data.sci+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name roadSpecialTs"> 桥隧构造物技术状况指数(BCI)：</div><div class="value specialValue">'+data.bci+'</div><div style="clear:both;"></div></li>'
	    			+'<li><div class="name roadSpecialTs"> 沿线设施技术状况指数(TCI)：</div><div class="value specialValue">'+data.tci+'</div><div style="clear:both;"></div></li>';
	    		break;
			default:;
    	}return html;
    };
	//高亮符号
	var hightimage = new ol.style.Icon({
		src: "/ssjc/images/gis/label-hong.png",
		scale: 0.8
	});
	var hightLightStyles = {
		'Point': new ol.style.Style({
			image: hightimage
		}),
		'LineString': new ol.style.Style({
			stroke: new ol.style.Stroke({
				color: '#00FFFF',
				width: 4
			})
		}),
		'MultiLineString': new ol.style.Style({
			stroke: new ol.style.Stroke({
				color: '#00FFFF',
				width: 4
			})
		}),
		'Polygon': new ol.style.Style({
			stroke: new ol.style.Stroke({
				color: '#00FFFF',
				lineDash: [4],
				width: 4
			}),
			fill: new ol.style.Fill({
				color: 'rgba(0, 0, 255, 0.1)'
			})
		})
	};
	var HightLightstyleFunction = function(feature) {
		return hightLightStyles[feature.getGeometry().getType()];
	};
	//基础符号
	var image = new ol.style.Icon({
		src: "/ssjc/images/gis/label-lan.png",
		scale: 0.8
	});
	var styles = {
		'Point': new ol.style.Style({
			image: image
		}),
		'LineString': new ol.style.Style({
			stroke: new ol.style.Stroke({
				color: '#CD00CD',
				width: 4
			})
		}),
		'MultiLineString': new ol.style.Style({
			stroke: new ol.style.Stroke({
				color: '#CD00CD',
				width: 4
			})
		}),
		'Polygon': new ol.style.Style({
			stroke: new ol.style.Stroke({
				color: 'blue',
				lineDash: [4],
				width: 4
			}),
			fill: new ol.style.Fill({
				color: 'rgba(0, 0, 255, 0.1)'
			})
		})
	};
	var styleFunction = function(feature) {
		return styles[feature.getGeometry().getType()];
	};
	//查询养护信息并定位
	function Querycuring(curingtype,id,year){
		m_reMoveLayerAndolay();
		var curingTypeData= curingData[curingtype];
		var dataUrl;
		if(!year) {
			dataUrl = curingTypeData.dataQuery.url + curingTypeData.dataQuery.queryField + "=" + id;
		}
		else {
			dataUrl = curingTypeData.dataQuery.queryAllurl + "roundId=" + id+"&year="+year;
		}
		$.get(dataUrl).
		then(function(response){
			var format = new ol.format.GeoJSON();
			var features;
			var detailSource = new ol.source.Vector();
			var detailLayer = new ol.layer.Vector({
				source: detailSource,
				style: styleFunction
			});
			features=format.readFeatures(response, {featureProjection: 'EPSG:3857'});
			if(features.length>0){
				for(var i=0;i<features.length;i++){
					features[i].set("type",messageMapp[curingtype]);
				}
			}
			detailSource.addFeatures(features);
			//结果定位
			if(features.length>0){
				map.getView().fit(detailSource.getExtent(),map.getSize(),{padding: [170, 50, 30, 150]});
			}
			m_TempLayer = detailLayer;
			map.addLayer(detailLayer);
		});
		var selectPointerMove = new ol.interaction.Select({
			condition: ol.events.condition.pointerMove
		});
		map.addInteraction(selectPointerMove);
		var pre;
		selectPointerMove.on("select", function(e) {
			var hit = !!e.target.getFeatures().getLength();
			map.getTargetElement().style.cursor = hit ? 'pointer' : 'default';
			if (hit) {
				pre && pre.setStyle(styleFunction(pre));
				pre = e.target.getFeatures().array_[0];
				pre.setStyle(HightLightstyleFunction(pre));
			} else {
				if(pre&&styleFunction) {
					pre.setStyle(styleFunction(pre));
				}
			}
		});
	};
    var lifeMessage = new lifeMessage ("#details");
});
